﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<sec:authentication property="principal" var="currentPrincipal" scope="page"/>

<fmt:setBundle basename="ApplicationMessage"/>
<fmt:setLocale value="zh_CN"/>

<!DOCTYPE html>
<html lang="zh-CN">
<head>

    <%@ include file="/WEB-INF/include/meta.jsp" %>
    <%@ include file="/WEB-INF/include/css.jsp" %>

</head>

<body class="ms-theme-blue">

<%@ include file="/WEB-INF/include/header.jsp" %>
<%@ include file="/WEB-INF/include/submenu.jsp" %>

<div class="container-fluid ms-container has-ms-sidemenu">

    <ol class="ms-breadcrumb breadcrumb">
        <li class="active">代理管理&nbsp;-&nbsp;二级代理列表</li>
    </ol>

    <div class="ms-content-layout">
        <div class="x-operation-bar no-margin no-bottom-border clearfix">

            <div class="ms-operation-bar no-margin no-bottom-border clearfix">
                <div class="ms-operation-group pull-right">
                    <a href="${ctx.host}/agents/search" data-target="#search" data-toggle="modal"
                       class="btn ms-btn ms-btn-blue"> <i class="glyphicon glyphicon-search"></i>&nbsp;&nbsp;筛选
                    </a>
                </div>
            </div>

            <table class="table table-hover ms-table">
                <thead>
                <tr>
                    <th>公司名称</th>
                    <th>代理类型</th>
                    <th>联系人名称</th>
                    <th>所属销售</th>
                    <th>上级代理</th>
                    <th>返点率</th>
                    <th>联系电话</th>
                    <th>Email</th>
                    <th>提成率</th>
                    <th class="text-center">操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="agentCompany" items="${agentCompanies}" varStatus="status">
                    <tr>
                        <c:choose>
                            <c:when test="${agentCompany.companyName == ''}">
                                <td><strong>-</strong></td>
                            </c:when>
                            <c:otherwise>
                                <td>${agentCompany.companyName}</td>
                            </c:otherwise>
                        </c:choose>
                        <td>${agentCompany.type.description }</td>
                        <td>${agentCompany.contactName}</td>
                        <td>${agentCompany.principal.name}</td>
                        <td>${agentCompany.primaryAgent.company.companyName} - ${agentCompany.primaryAgent.name}</td>
                        <td><fmt:formatNumber type="percent" maxFractionDigits="4" pattern="0.00%"
                                              value="${agentCompany.rate/100}"/></td>
                        <td>${agentCompany.conactMobile}</td>
                        <td>${agentCompany.contactEmail}</td>
                        <td>${agentCompany.primaryAgentRate}%</td>
                        <td class="text-center">
                            <a href="${ctx.host}/secondary-agents/${agentCompany.id}">详情</a>
                            <c:if test="${currentPrincipal.admin}">
                                <a href="${ctx.host}/agents/${agentCompany.id}/edit " data-target="#edit"
                                   data-toggle="modal">编辑</a>&nbsp;&nbsp;
                            </c:if>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="10" class="no-vertical-padding">
                        <div class="pull-left">
                            <jsp:include page="/WEB-INF/include/page.jsp">
                                <jsp:param name="url" value="${ctx.host}/agents"/>
                                <jsp:param name="queryString" value="${queryString}"/>
                            </jsp:include>
                        </div>
                    </td>
                </tr>
                </tfoot>
            </table>
        </div>
    </div>
</div>
<%@ include file="/WEB-INF/include/footer.jsp" %>
<%@ include file="/WEB-INF/include/script.jsp" %>
<d:resource root="${ctx.resource}/build" type="script" src="js/page/agent/agent-list.js"/>
<script type="text/javascript">
    require(['page/agent/agent-list'], function (page) {
        page.init();
    })
</script>
</body>
</html>